package com.zhc.dejingapi.service.upload.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhc.dejingapi.entity.QingAppinfoEntity;
import com.zhc.dejingapi.entity.QingFcmoroutingdetailEntity;
import com.zhc.dejingapi.entity.QingFcmoroutingmainEntity;
import com.zhc.dejingapi.entity.QingWaterboiltaskfinishEntity;
import com.zhc.dejingapi.entity.query.CodeQuery;
import com.zhc.dejingapi.entity.vo.CodeVo;
import com.zhc.dejingapi.mapper.*;
import com.zhc.dejingapi.pojo.param.QingCommonBackResult;
import com.zhc.dejingapi.pojo.param.QingFcmoroutingDetailParam;
import com.zhc.dejingapi.pojo.param.QingFcmoroutingMainParam;
import com.zhc.dejingapi.pojo.param.QingWaterboiltaskfinishParam;
import com.zhc.dejingapi.pojo.qingflow.QingflowApiInfo;
import com.zhc.dejingapi.pojo.qingflow.appdata.adddata.QingAddDataResultMain;
import com.zhc.dejingapi.pojo.qingflow.queryresult.QingQueryActionResultBase;
import com.zhc.dejingapi.service.upload.IQingFcMoroutingMainReportService;
import com.zhc.dejingapi.utils.fcmoroutingmain.FCPubInfo;
import com.zhc.dejingapi.utils.qing.CommonAppFieldValueUpdateUtils;
import com.zhc.dejingapi.utils.qing.FCMoRoutingUploadUtils;
import com.zhc.dejingapi.utils.qing.QingflowAPIUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

@Service
@Slf4j
public class QingFcMoroutingMainReportServiceImpl implements IQingFcMoroutingMainReportService {

    @Autowired
    private QingAppinfoMapper qingAppinfoMapper;

    @Autowired
    private QingAppfieldsMapper qingAppfieldsMapper;
    @Autowired
    private QingAppfieldtablevaluesMapper qingAppfieldtablevaluesMapper;
    @Autowired
    QingflowApiInfo qqingflowApiInfo;

    @Autowired
    private QingFcmoroutingmainMapper qingFcmoroutingmainMapper;

    @Autowired
    private QingFcmoroutingdetailMapper qingFcmoroutingdetailMapper;


    @Autowired
    private QingWaterboiltaskfinishMapper qingWaterboiltaskfinishMapper;

    private final JdbcTemplate mysqlJdbcTemplate;

    private final RedisTemplate<String,Object> redisTemplate;


    public QingFcMoroutingMainReportServiceImpl(@Qualifier("mySqlJdbcTemplate")JdbcTemplate mysqlJdbcTemplate1,
                                                @Qualifier("redisTemplateWin")RedisTemplate<String, Object> redisTemplate1) {
        this.redisTemplate = redisTemplate1;
        this.mysqlJdbcTemplate = mysqlJdbcTemplate1;
    }


    @Override
    public QingCommonBackResult ReportJob(QingFcmoroutingMainParam param) {
        QingCommonBackResult commonBackResult=new QingCommonBackResult();

        String strAppKey=param.getAppKey();
        Long mainId=0l;
        CommonAppFieldValueUpdateUtils appFieldValueUpdateUtils=null;
        try{

            //region 保存到数据库
            QingFcmoroutingmainEntity mainEntity= new QingFcmoroutingmainEntity();
            QingFcmoroutingdetailEntity detailEntity=null;

            mainEntity= FCMoRoutingUploadUtils.CopyFromParam(param);

            qingFcmoroutingmainMapper.insert(mainEntity);

            mainId=mainEntity.getMainId();

            List<QingFcmoroutingDetailParam> listBarcodes=new ArrayList<>();
            param.setQingFcmoroutingdetail(listBarcodes);

            if(param.getQingFcmoroutingdetail()==null||param.getQingFcmoroutingdetail().size()==0){

                int iBeginRowIndex=1;
                String strSql="SELECT COUNT(*)\n" +
                        "from qing_fcmoroutingdetail a\n" +
                        "INNER JOIN qing_fcmoroutingmain b on a.main_id=b.main_id\n" +
                        "where b.zsSendWorkCode=? \n" +
                        "  and  IFNULL(a.qingApplyId,0)>0";
                int iHaveRowCount=mysqlJdbcTemplate.queryForObject(strSql,Integer.class,param.getZsSendWorkCode());
                if(iHaveRowCount<1){
                    iBeginRowIndex=1;
                }
                else{
                    strSql="SELECT a.barcodeStr\n" +
                            "from qing_fcmoroutingdetail a\n" +
                            "INNER JOIN qing_fcmoroutingmain b on a.main_id=b.main_id\n" +
                            "where b.zsSendWorkCode=? and IFNULL(a.qingApplyId,0)>0\n" +
                            "ORDER BY a.barcodeStr desc\n" +
                            "LIMIT 1";
                    String strBarcodeStr=mysqlJdbcTemplate.queryForObject(strSql,String.class,param.getZsSendWorkCode());
                    if(strBarcodeStr==null||strBarcodeStr.isEmpty()){
                        iBeginRowIndex=1;
                    }
                    else{
                        if(strBarcodeStr.contains("-")){
                            int iIndex=strBarcodeStr.lastIndexOf("-");
                            iBeginRowIndex=Integer.parseInt(strBarcodeStr.substring(iIndex+1));
                            iBeginRowIndex++;
                        }
                    }
                }

                SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMdd");
                String strDateNow=sdf.format(new java.util.Date());


                Integer proNum= param.getProNum();//箱数
                Integer qtyPerCarton = param.getQtyPerCarton();//单箱数量/件

                Integer modQty= param.getModQty();//尾箱数量/件
                if(modQty<0){
                    proNum-=1;
                }
                for (int i = 0; i < proNum-1; i++) {


                    detailEntity = new QingFcmoroutingdetailEntity();

                    detailEntity.setMainId(mainId);
                    QingFcmoroutingDetailParam detailParam = new QingFcmoroutingDetailParam();

                    String strBarCode = param.getZsSendWorkCode() + "-" + strDateNow + "-" + iBeginRowIndex;

                    detailEntity.setBarcodeStr(strBarCode);
                    detailEntity.setINum(1);
                    detailEntity.setIQty(qtyPerCarton);


                    detailParam.setBarcodeStr(strBarCode);
                    detailParam.setInum(1);
                    detailParam.setIqty(qtyPerCarton);


                    qingFcmoroutingdetailMapper.insert(detailEntity);


                    iBeginRowIndex++;
                    listBarcodes.add(detailParam);
                }
                if(modQty>0){

                    detailEntity = new QingFcmoroutingdetailEntity();

                    detailEntity.setMainId(mainId);
                    QingFcmoroutingDetailParam detailParam = new QingFcmoroutingDetailParam();

                    String strBarCode = param.getZsSendWorkCode() + "-" + strDateNow + "-" + iBeginRowIndex;

                    detailEntity.setBarcodeStr(strBarCode);
                    detailEntity.setINum(1);
                    detailEntity.setIQty(modQty);

                    detailParam.setBarcodeStr(strBarCode);
                    detailParam.setInum(1);
                    detailParam.setIqty(modQty);

                    qingFcmoroutingdetailMapper.insert(detailEntity);

//                    QingFcmoroutingDetailParam qingFcmoroutingDetailParam = new QingFcmoroutingDetailParam();
//                    qingFcmoroutingDetailParam.setBarcodeStr(strBarCode);

                    iBeginRowIndex++;
                    listBarcodes.add(detailParam);
                }

                param.setQingFcmoroutingdetail(listBarcodes);

                for (int i = 0; i < param.getQingFcmoroutingdetail().size(); i++) {

                    detailEntity = new QingFcmoroutingdetailEntity();

                    detailEntity.setMainId(mainId);
                    QingFcmoroutingDetailParam detailParam = new QingFcmoroutingDetailParam();

                    String strBarCode = param.getZsSendWorkCode() + "-" + strDateNow + "-" + iBeginRowIndex;

                    detailEntity.setBarcodeStr(strBarCode);
                    detailEntity.setINum(1);
                    //detailEntity.setBarcodeStr(param.getQingFcmoroutingdetail().get(i).getBarcodeStr());
                    //param.getQingFcmoroutingdetail().get(i).setBarcodeStr(strBarCode);
                    detailEntity.setIQty(param.getQingFcmoroutingdetail().get(i).getIqty());

                    qingFcmoroutingdetailMapper.insert(detailEntity);

//                    QingFcmoroutingDetailParam qingFcmoroutingDetailParam = new QingFcmoroutingDetailParam();
//                    qingFcmoroutingDetailParam.setBarcodeStr(strBarCode);
//
//                    listBarcodes.add(qingFcmoroutingDetailParam);
                    iBeginRowIndex++;
                }

                param.setQingFcmoroutingdetail(listBarcodes);

            }
            //endregion

            QingAppinfoEntity appinfoEntity=qingAppinfoMapper.selectOne(
                    new QueryWrapper<QingAppinfoEntity>().eq("appKey",strAppKey));
            if(appinfoEntity==null||appinfoEntity.getIsDelete()==1){

                throw new Exception("当前appkey的信息不存在，或者已经删除，或者未下载。");
            }
            if (appinfoEntity.getAppName().equals("注塑报工")) {




                try{
                    if (FCPubInfo.fcInjectUploadUtils==null){
                        FCPubInfo.LoadInjectUploadUtils( strAppKey,
                                qqingflowApiInfo,
                                qingAppfieldsMapper,
                                qingAppfieldtablevaluesMapper,
                                mysqlJdbcTemplate);
                    }

                }
                catch (Exception e){
                    e.printStackTrace();
                    log.error(e.getMessage()+"\n"+e.getStackTrace());
                    commonBackResult.setErrCode(-10049);
                    commonBackResult.setErrMsg("创建提交对象出错："+e.getMessage()+"\n"+e.getStackTrace());
                    return commonBackResult;
                }

                if(FCPubInfo.fcInjectUploadUtils==null){
                    commonBackResult.setErrCode(-10045);
                    commonBackResult.setErrMsg("提交对象创建失败！");
                    return commonBackResult;
                }

                try {

                    //region 新增注塑报工

                    try {

                        QingAddDataResultMain resultMain = FCPubInfo.fcInjectUploadUtils.AddEntity(param);
                        //region 处理返回结果
                        if (resultMain == null) {

                            commonBackResult.setErrCode(-10015);
                            commonBackResult.setErrMsg("服务器返回内容为空！");

                        } else {
                            if (resultMain.getErrCode() == 0) {
                                commonBackResult.setErrCode(resultMain.getErrCode());
                                commonBackResult.setErrMsg("提交成功！");
                                commonBackResult.setBackValue(resultMain.getResult().getRequestId());
                                commonBackResult.setMainId(mainId);
                                //获取查询值的结果
                                String strRequestId=resultMain.getResult().getRequestId();
                                try{
                                    Thread.sleep(500);
                                }
                                catch (Exception e){
                                    e.printStackTrace();
                                }
                                QingQueryActionResultBase actionResultBase= QingflowAPIUtils.GetRequestResult(qqingflowApiInfo,strRequestId);
                                if (actionResultBase==null){
                                    commonBackResult.setErrCode(-10066);
                                    commonBackResult.setErrMsg("提交成功：获取提交结果的内容为空！");

                                }
                                else{
                                    if (actionResultBase.getErrorCode()==0){

                                        commonBackResult.setErrCode(0);
                                        commonBackResult.setErrMsg("提交成功！");
                                        String strValue=actionResultBase.getResult();
                                        if (strValue==null||strValue.isEmpty()){

                                        }
                                        else{
                                            Long lValue=Long.parseLong(actionResultBase.getResult());
                                            commonBackResult.setBackLongValue(lValue);
                                        }
                                        //try{
                                            //new Thread(()-> {
                                        //    FCPubInfo.UpdateTaskFinishQty(FCPubInfo.fcInjectUpdBackUtils,param.getWorkTaskCode(),mysqlJdbcTemplate);
                                        appFieldValueUpdateUtils=FCPubInfo.fcInjectUpdBackUtils;
                                            // });
                                        //}
                                        //catch (Exception e){
                                        //    e.printStackTrace();
                                        //    log.error(e.getMessage()+"\n"+e.getStackTrace());
                                        //}
                                    }
                                    else{

                                        commonBackResult.setErrCode(actionResultBase.getErrorCode());
                                        commonBackResult.setErrMsg(actionResultBase.getMessage());

                                    }
                                }

                            } else {
                                commonBackResult.setErrCode(resultMain.getErrCode());
                                commonBackResult.setErrMsg(resultMain.getErrMsg());

                            }

                        }
                        //endregion
                    } catch (Exception e) {
                        e.printStackTrace();

                        commonBackResult.setErrCode(-10076);
                        commonBackResult.setErrMsg(e.getMessage() + "\n" + e.getStackTrace());

                    }

                    //endregion

                }
                catch (Exception e){
                    e.printStackTrace();
                    commonBackResult.setErrCode(-10076);
                    commonBackResult.setErrMsg(e.getMessage() + "\n" + e.getStackTrace());

                }


            }
            else if (appinfoEntity.getAppName().equals("后道报工")){
                if(param.getAfteScrapQty()==null){
                    param.setAfteScrapQty(0);
                }


                try{
                   if(FCPubInfo.fcPressUploadUtils==null){
                       FCPubInfo.LoadPressUploadUtils( strAppKey,
                               qqingflowApiInfo,
                               qingAppfieldsMapper,
                               qingAppfieldtablevaluesMapper,
                               mysqlJdbcTemplate);
                   }
                }
                catch (Exception e){
                    log.error(e.getMessage()+"\n"+e.getStackTrace());
                    commonBackResult.setErrCode(-10049);
                    commonBackResult.setErrMsg("创建提交对象出错："+e.getMessage()+"\n"+e.getStackTrace());
                    return commonBackResult;
                }

                if(FCPubInfo.fcInjectUploadUtils==null){
                    commonBackResult.setErrCode(-10045);
                    commonBackResult.setErrMsg("提交对象创建失败！");
                    return commonBackResult;
                }

                try {

                    //region 新增初始行

                    try {

                        QingAddDataResultMain resultMain = FCPubInfo.fcPressUploadUtils.AddEntity(param);
                        //region 处理返回结果
                        if (resultMain == null) {

                            commonBackResult.setErrCode(-10015);
                            commonBackResult.setErrMsg("服务器返回内容为空！");

                        } else {
                            if (resultMain.getErrCode() == 0) {
                                commonBackResult.setErrCode(resultMain.getErrCode());
                                commonBackResult.setErrMsg("提交成功！");
                                commonBackResult.setBackValue(resultMain.getResult().getRequestId());
                                //获取查询值的结果
                                String strRequestId=resultMain.getResult().getRequestId();

                                try{
                                    Thread.sleep(500);
                                }
                                catch (Exception e){
                                    e.printStackTrace();
                                }

                                QingQueryActionResultBase actionResultBase= QingflowAPIUtils.GetRequestResult(qqingflowApiInfo,strRequestId);
                                if (actionResultBase==null){
                                    commonBackResult.setErrCode(-10066);
                                    commonBackResult.setErrMsg("提交成功：获取提交结果的内容为空！");

                                }
                                else{
                                    if (actionResultBase.getErrorCode()==0){

                                        commonBackResult.setErrCode(0);
                                        commonBackResult.setErrMsg("提交成功！");
                                        String strValue=actionResultBase.getResult();
                                        if (strValue==null||strValue.isEmpty()){

                                        }
                                        else{
                                            Long lValue=Long.parseLong(actionResultBase.getResult());
                                            commonBackResult.setBackLongValue(lValue);
                                        }

                                        //try{
                                            //new Thread(()-> {
                                                //FCPubInfo.UpdateTaskFinishQty(FCPubInfo.fcPressUpdBackUtils,param.getWorkTaskCode(),mysqlJdbcTemplate);
                                        appFieldValueUpdateUtils=FCPubInfo.fcPressUpdBackUtils;
                                           // });
                                        //}
                                        //catch (Exception e){
                                        //    e.printStackTrace();
                                        //}


                                        //commonBackResult.setBackValue(actionResultBase.getResult());
                                        //保存到数据库

                                    }
                                    else{

                                        commonBackResult.setErrCode(actionResultBase.getErrorCode());
                                        commonBackResult.setErrMsg(actionResultBase.getMessage());

                                    }
                                }

                            } else {
                                commonBackResult.setErrCode(resultMain.getErrCode());
                                commonBackResult.setErrMsg(resultMain.getErrMsg());

                            }

                        }
                        //endregion
                    } catch (Exception e) {
                        e.printStackTrace();

                        commonBackResult.setErrCode(-10076);
                        commonBackResult.setErrMsg(e.getMessage() + "\n" + e.getStackTrace());

                    }

                    //endregion

                }
                catch (Exception e){
                    e.printStackTrace();
                    commonBackResult.setErrCode(-10076);
                    commonBackResult.setErrMsg(e.getMessage() + "\n" + e.getStackTrace());

                }

            }
            else if (appinfoEntity.getAppName().equals("水煮结束报工")){
                //水煮结束报工

            }

        }
        catch (Exception e){
            e.printStackTrace();
            commonBackResult.setErrCode(-10012);
            commonBackResult.setErrMsg("出错："+e.getMessage()+"\n"+e.getStackTrace());
        }


        //回写数据库结果
        String strSql="UPDATE qing_fcmoroutingmain set errCode=?, errMsg=?, lastRequestId=?, qingApplyId=? where main_id=?";
        List<Object> listPara=new ArrayList<>();
        listPara.add(commonBackResult.getErrCode());
        listPara.add(commonBackResult.getErrMsg());
        listPara.add(commonBackResult.getBackValue());
        listPara.add(commonBackResult.getBackLongValue());
        listPara.add(mainId);
        mysqlJdbcTemplate.update(strSql,listPara.toArray());

        strSql="UPDATE  qing_fcmoroutingdetail set qingApplyId=? where main_id=?";
        listPara=new ArrayList<>();
        listPara.add(commonBackResult.getBackLongValue());
        listPara.add(mainId);
        mysqlJdbcTemplate.update(strSql,listPara.toArray());


        //回写合计数

        if(appFieldValueUpdateUtils==null){

        }
        else{
            try{
                //new Thread(()-> {
                FCPubInfo.UpdateTaskFinishQty(appFieldValueUpdateUtils,param.getZsSendWorkCode(),mysqlJdbcTemplate);
                // });
            }
            catch (Exception e){
                e.printStackTrace();
                log.error(e.getMessage()+"\n"+e.getStackTrace());
            }
        }

        return commonBackResult;

    }

    @Override
    public QingCommonBackResult ReportBoil(QingWaterboiltaskfinishParam param) {
        QingCommonBackResult commonBackResult=new QingCommonBackResult();

       String strAppKey="7v93shmc1o01";
        //87	7ta9tpm01o02	水煮报工
        //117	7vick5u81o01	水煮结束报工
        //118	7v93shmc1o01	水煮启动报工
        Long mainId=0l;
        CommonAppFieldValueUpdateUtils appFieldValueUpdateUtils=null;
        try {

            //region 保存到数据库
            QingWaterboiltaskfinishEntity mainEntity = new QingWaterboiltaskfinishEntity();
            QingFcmoroutingdetailEntity detailEntity = null;

            mainEntity = FCMoRoutingUploadUtils.CopyFromWaterBoildEndParam(param);

            qingWaterboiltaskfinishMapper.insert(mainEntity);

            mainId = mainEntity.getMainId();


            //endregion

            try {
                if (FCPubInfo.fcWaterBoilEndUploadUtils == null) {
                    FCPubInfo.LoadWaterBoiledEndUpdBackUtils(strAppKey,
                            qqingflowApiInfo,
                            qingAppfieldsMapper,
                            qingAppfieldtablevaluesMapper,
                            mysqlJdbcTemplate);
                }

            } catch (Exception e) {
                e.printStackTrace();
                log.error(e.getMessage() + "\n" + e.getStackTrace());
                commonBackResult.setErrCode(-10049);
                commonBackResult.setErrMsg("创建提交对象出错：" + e.getMessage() + "\n" + e.getStackTrace());
                return commonBackResult;
            }

            if (FCPubInfo.fcWaterBoilEndUploadUtils == null) {
                commonBackResult.setErrCode(-10045);
                commonBackResult.setErrMsg("提交对象创建失败！");
                return commonBackResult;
            }

            try {

                //region 新增报工

                try {

                    QingAddDataResultMain resultMain = FCPubInfo.fcWaterBoilEndUploadUtils.AddWorterBoiledEndEntity(param);
                    //region 处理返回结果
                    if (resultMain == null) {

                        commonBackResult.setErrCode(-10015);
                        commonBackResult.setErrMsg("服务器返回内容为空！");

                    } else {
                        if (resultMain.getErrCode() == 0) {
                            commonBackResult.setErrCode(resultMain.getErrCode());
                            commonBackResult.setErrMsg("提交成功！");
                            commonBackResult.setBackValue(resultMain.getResult().getRequestId());
                            //获取查询值的结果
                            String strRequestId = resultMain.getResult().getRequestId();
                            try {
                                Thread.sleep(500);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            QingQueryActionResultBase actionResultBase = QingflowAPIUtils.GetRequestResult(qqingflowApiInfo, strRequestId);
                            if (actionResultBase == null) {
                                commonBackResult.setErrCode(-10066);
                                commonBackResult.setErrMsg("提交成功：获取提交结果的内容为空！");

                            } else {
                                if (actionResultBase.getErrorCode() == 0) {

                                    commonBackResult.setErrCode(0);
                                    commonBackResult.setErrMsg("提交成功！");
                                    String strValue = actionResultBase.getResult();
                                    if (strValue == null || strValue.isEmpty()) {

                                    } else {
                                        Long lValue = Long.parseLong(actionResultBase.getResult());
                                        commonBackResult.setBackLongValue(lValue);
                                    }
                                    //try{
                                    //new Thread(()-> {
                                    //    FCPubInfo.UpdateTaskFinishQty(FCPubInfo.fcInjectUpdBackUtils,param.getWorkTaskCode(),mysqlJdbcTemplate);
                                    appFieldValueUpdateUtils = FCPubInfo.LoadWaterBoildEndBackUtils;
                                    // });
                                    //}
                                    //catch (Exception e){
                                    //    e.printStackTrace();
                                    //    log.error(e.getMessage()+"\n"+e.getStackTrace());
                                    //}
                                } else {

                                    commonBackResult.setErrCode(actionResultBase.getErrorCode());
                                    commonBackResult.setErrMsg(actionResultBase.getMessage());

                                }
                            }

                        } else {
                            commonBackResult.setErrCode(resultMain.getErrCode());
                            commonBackResult.setErrMsg(resultMain.getErrMsg());

                        }

                    }
                    //endregion
                } catch (Exception e) {
                    e.printStackTrace();

                    commonBackResult.setErrCode(-10076);
                    commonBackResult.setErrMsg(e.getMessage() + "\n" + e.getStackTrace());

                }

                //endregion

            } catch (Exception e) {
                e.printStackTrace();
                commonBackResult.setErrCode(-10076);
                commonBackResult.setErrMsg(e.getMessage() + "\n" + e.getStackTrace());

            }


        }
        catch (Exception e){
            e.printStackTrace();
            commonBackResult.setErrCode(-10012);
            commonBackResult.setErrMsg("出错："+e.getMessage()+"\n"+e.getStackTrace());
        }


        //回写数据库结果
        String strSql="UPDATE qing_waterboiltaskfinish set errCode=?, errMsg=?, lastRequestId=?, qingApplyId=? where main_id=?";
        List<Object> listPara=new ArrayList<>();
        listPara.add(commonBackResult.getErrCode());
        listPara.add(commonBackResult.getErrMsg());
        listPara.add(commonBackResult.getBackValue());
        listPara.add(commonBackResult.getBackLongValue());
        listPara.add(mainId);
        mysqlJdbcTemplate.update(strSql,listPara.toArray());

        //回写合计数

        if(appFieldValueUpdateUtils==null){

        }
        else{
            try{
                //new Thread(()-> {
                FCPubInfo.UpdateWaterBoilStartQty(appFieldValueUpdateUtils,param.getBoilStartRowNo(),mysqlJdbcTemplate);
                // });
            }
            catch (Exception e){
                e.printStackTrace();
                log.error(e.getMessage()+"\n"+e.getStackTrace());
            }
        }

        return commonBackResult;

    }

    @Override
    public PageInfo<CodeVo> getCodeList(CodeQuery codeQuery) {
        int current=codeQuery.getPageCurrent();
        int size=codeQuery.getPageSize();

        //获取第1页，10条内容，默认查询总数count
        PageHelper.startPage(current, size);
        //只有紧跟着PageHelper.startPage()的sql起了作用
        List<CodeVo> codeList = qingFcmoroutingmainMapper.getCodeList(codeQuery);
        //用PageInfo对结果进行包装
        PageInfo<CodeVo> page = new PageInfo<>(codeList);

        return page;
    }
}
